<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }
    </style>

</head>
<body>

<div id="app">
    <!--搜索表单-->
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="当前状态">
            <el-input v-model="formInline.status" placeholder="当前状态"></el-input>
        </el-form-item>
        <el-form-item label="企业名称">
            <el-input v-model="formInline.companyName" placeholder="企业名称"></el-input>
        </el-form-item>
        <el-form-item label="品牌名称">
            <el-input v-model="formInline.brandName" placeholder="品牌名称"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
    </el-form>

    <!--批量删除 新增按钮-->
    <el-row>
        <el-button type="danger" plain>批量删除</el-button>
        <el-button type="primary" @click="dialogFormVisible = true" plain>新增</el-button>
    </el-row>

    <!--新增对话框-->
    <el-dialog title="编辑品牌" :visible.sync="dialogFormVisible">
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="品牌名称">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="企业名称">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="排序">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" v-model="form.desc"></el-input>
            </el-form-item>
            <el-form-item label="状态">
                <el-switch v-model="form.delivery"></el-switch>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">提交</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
    <!--表格-->
    <el-table
            :data="brands"
            style="width: 100%"
            :row-class-name="tableRowClassName"
            @selection-change="handleSelectionChange">
        <el-table-column
                type="selection"
                width="55">
        </el-table-column>
        <el-table-column
                type="index"
                width="50">
        </el-table-column>
        <el-table-column
                prop="brandName"
                label="品牌名称"
                align="center">
        </el-table-column>
        <el-table-column
                prop="companyName"
                label="企业名称"
                align="center">
        </el-table-column>
        <el-table-column
                prop="ordered"
                label="排序"
                align="center">
        </el-table-column>
        <el-table-column
                prop="status"
                label="当前状态"
                align="center">
        </el-table-column>
        <el-table-column
                prop="status"
                label="操作"
                align="center">
            <el-row>
                <el-button type="primary" size="small">修改</el-button>
                <el-button type="danger" size="small">删除</el-button>
            </el-row>
            <el-row>
            </el-row>
        </el-table-column>
    </el-table>

    <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="5"
            layout="total, sizes, prev, pager, next, jumper"
            :total="80">
    </el-pagination>
</div>


<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                //当前页码
                currentPage: 4,
                //对话框属性
                dialogFormVisible: false,
                //对话框表格模型
                form: {
                    name: '',
                    region: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: ''
                },
                //多选框数据
                multipleSelection:[],
                //表格模型
                brands: [{
                    brandName: '小米',
                    companyName: '小米科技有限公司',
                    ordered: '10',
                    description: '小米手机',
                    status: '启用'
                }, {
                    brandName: '小米',
                    companyName: '小米科技有限公司',
                    ordered: '10',
                    description: '小米手机',
                    status: '启用'
                }, {
                    brandName: '小米',
                    companyName: '小米科技有限公司',
                    ordered: '10',
                    description: '小米手机',
                    status: '启用'
                }, {
                    brandName: '小米',
                    companyName: '小米科技有限公司',
                    ordered: '10',
                    description: '小米手机',
                    status: '启用'
                }],
                //搜索表单模型
                formInline: {
                    status: '',
                    companyName: '',
                    brandName: ''
                }
            }
        },
        methods: {
            tableRowClassName({row, rowIndex}) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            //搜索表单提交事件
            onSubmit() {
                console.log('submit!');
            },
            //多选框返回数据方法
            handleSelectionChange(val) {
                this.multipleSelection= val;
                console.log(this.multipleSelection)
            },
            //新增表单提交事件
            onSubmit() {
                console.log('submit!');
            },
            //页码方法
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            }
        }
    })
</script>
</body>
</html>